#!/usr/bin/python
# -*-coding:utf-8 -*-
#奇偶排序
#@author: wklken@yeah.net

def oddeven_sort(l):
    print l
    size = len(l)
    odd_range = range(0,size-1,2)
    even_range = range(1,size-1,2)
    sign = 1
    while sign:
        sign = 0
      
        for i in odd_range:
            if l[i] > l[i+1]:
                l[i], l[i+1] = l[i+1],l[i]
                sign = 1
        print "odd range",l
        for j in even_range:
            if l[j] > l[j+1]:
                l[j], l[j+1] = l[j+1], l[j]
                sign = 1
        print "even range",l
    print l 
        

l = [ 50,10,30,20,60,40,1]
oddeven_sort(l)